#ifndef SERIAL_TX_THREAD_H
#define SERIAL_TX_THREAD_H

#include <QObject>
#include <QMutex>
#include <QDebug>
#include <QThread>
#include <QSemaphore>

#include "serial_port/serial_port.h"

namespace  {
    QSemaphore tx_sem(1);
}


class Serial_Tx_Thread : public QObject
{
    Q_OBJECT
public:
        Serial_Tx_Thread(Serial_Port* sp = nullptr);
        ~Serial_Tx_Thread();


        void stop_thread();

signals:
        void signal_start_tx_thread();
        void signal_start_serial_port(char *s,int len);

public slots:
        void slot_serial_port_tx_thread();
        void slot_write_serial_port_tx_queue(char *s, unsigned int len);
        void slot_tx_semaphore_release(qint64 bytes);

private:
        bool stop_flag;
        QMutex stop_mutex;
        Serial_Port *serial_port;
};





#endif
